home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / TransSkel.cpt / MultiSkel.pas < prev    next >
Pascal/Delphi Source File  |  1987-01-08  |  4KB  |  145 lines

  1. {    TransSkel multiple-window demonstration: main module}
  2.  
  3. {    This module performs setup and termination operations, installs}
  4. {    the window and menu handlers, and processes menu item selections.}
  5.  
  6. {    There are four window handlers in this demonstration.  The code}
  7. {    for each handler is in its own module.}
  8.  
  9. {    Help Window        Scrollable non-editable text window}
  10. {    Edit Window        Non-scrollable editable text window}
  11. {    Zoom Window        Non-manipulable graphics display window}
  12. {    Region Window    Manipulable graphics display window}
  13.  
  14. {    The project should include MacTraps,MacPasLib, TransSkelPas (or a project built}
  15. {    from TransSkelPas), MSkelHelp.pas, MSkelEdit.pas, MSkelZoom.pas and}
  16. {    MSkelRgn.pas.  You'll also need the MultiSkel.globals and common.pas header files.}
  17.  
  18. {    24 June 1986        Paul DuBois}
  19. {    8 January 1987     Ported to LightSpeed Pascal by Owen Hartnett        }
  20. {    Ωhm Software Company, 163 Richard Drive, Tiverton, RI 02878    }
  21.  
  22.  
  23. PROGRAM MultiSkel;
  24.  
  25.     USES
  26.         regionpas, MultiSkelGlobs, common, TransSkelpas, MSkelZoom, MultiSkelEdit, MSkelHelp;
  27.  
  28. { file menu item numbers }
  29.  
  30.     CONST
  31.         open = 1;
  32.         close = 2;
  33.         quit = 4;
  34.  
  35. {    Menu handles.  There isn't any apple menu here, since TransSkel will}
  36. {    be told to handle it itself.}
  37.  
  38.     VAR
  39.         filemenu : menuhandle;
  40.  
  41. {    Handle selection of About MultiSkel… item from Apple menu}
  42.  
  43.     PROCEDURE DoAbout;
  44.  
  45.         VAR
  46.             ignore : integer;
  47.     BEGIN
  48.         ignore := Alert(aboutAlrt, NIL);
  49.     END;
  50.  
  51. {    Show a window if it's not visible.  Select the window FIRST, then}
  52. {    show it, so that it comes up in front.  Otherwise it will be drawn}
  53. {    in back then brought to the front, which is ugly.}
  54.  
  55.  
  56.     PROCEDURE MyShowWindow (wind : WindowPeek);
  57.     BEGIN
  58.         IF (wind^.visible = false) THEN
  59.             BEGIN
  60.                 SelectWindow(WindowPtr(wind));
  61.                 ShowWindow(WindowPtr(wind));
  62.             END;
  63.     END;
  64.  
  65. {    Process selection from File menu.}
  66.  
  67. {    Open    Make all four windows visible}
  68. {    Close    Hide the frontmost window.  If it belongs to a desk accessory,}
  69. {            close the accessory.}
  70. {    Quit    Request a halt by calling SkelHalt().  This makes SkelMain}
  71. {            return.}
  72.  
  73.     PROCEDURE DoFile (item : integer);
  74.  
  75.         VAR
  76.             wPeek : WindowPeek;
  77.  
  78.     BEGIN
  79.         CASE item OF
  80.             open : 
  81.                 BEGIN
  82.                     MyShowWindow(WindowPeek(rgnWind));
  83.                     MyShowWindow(WindowPeek(zoomWind));
  84.                     MyShowWindow(WindowPeek(editWind));
  85.                     MyShowWindow(WindowPeek(helpWind));
  86.                 END;
  87.             close : 
  88.  
  89. {    Close the front window.  Take into account whether it belongs}
  90. {    to a desk accessory or not.}
  91.  
  92.                 BEGIN
  93.                     wPeek := WindowPeek(FrontWindow);
  94.                     IF wPeek <> NIL THEN
  95.                         BEGIN
  96.                             IF (wPeek^.windowKind < 0) THEN
  97.                                 CloseDeskAcc(wPeek^.windowKind)
  98.                             ELSE
  99.                                 HideWindow(FrontWindow);
  100.                         END;
  101.                 END;
  102.             quit : 
  103.                 SkelWhoa;        { request halt }
  104.         END;
  105.     END;
  106.  
  107. {    Process item selected from Edit menu.  First check whether it should}
  108. {    get routed to a desk accessory or not.  If not, then for route the}
  109. {    selection to the text editing window, as that is the only one for}
  110. {    this application to which edit commands are valid.}
  111. {    (The test of FrontWindow is not strictly necessary, as the Edit}
  112. {    menu is disabled when any of the other windows is frontmost, and so}
  113. {    this Proc couldn't be called.)}
  114.  
  115.     PROCEDURE DoEdit (item : integer);
  116.  
  117.     BEGIN
  118.         IF NOT SystemEdit(item - 1) THEN        { check DA edit choice }
  119.             IF FrontWindow = editWind THEN
  120.                 EditWindEditMenu(item);
  121.     END;
  122.  
  123. {    Initialize menus.  Tell Skel to process the Apple menu automatically,}
  124. {    and associate the proper procedures with the File and Edit menus.}
  125.  
  126.     PROCEDURE SetUpMenus;
  127.  
  128.     BEGIN
  129.         SkelApple('About MultiSkel...', @DoAbout);
  130.         fileMenu := GetMenu(fileMenuRes);
  131.         editMenu := GetMenu(editMenuRes);
  132.         SkelMenu(fileMenu, @DoFile, NIL);
  133.         SkelMenu(editMenu, @DoEdit, NIL);
  134.     END;
  135.  
  136. BEGIN
  137.     SkelInit;
  138.     SetUpMenus;            { install menu handlers }
  139.     RgnWindInit;        { install window handlers  }
  140.     ZoomWindInit;
  141.     EditWindInit;
  142.     HelpWindInit;
  143.     SkelMain;
  144.     SkelClobber;        { throw away windows and menus }
  145. END.